﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace JumpNFight.Simulation
{
    /// <summary>
    /// Stores a message (used when crate is hit)
    /// </summary>
    class CrateMessage
    {
        float m_spawTime;
        Vector2 m_velocity = Configuration.CrateMessageVelocity;
        public Vector2 Position;
        public string Message
        {
            get;
            private set;
        }

        public bool IsActive
        {
            get;
            private set;
        }
        public CrateMessage(GameTime gameTime, Vector2 position, string msg)
        {
            IsActive = true;
            Position = position;
            Message = msg;
            m_spawTime = (float)gameTime.TotalGameTime.TotalSeconds;
        }

        public void Update(GameTime gameTime)
        { 
            double currentTime = (float)gameTime.TotalGameTime.TotalSeconds;
            if ( currentTime - m_spawTime > Configuration.CrateMessageLifetime)
            {
                IsActive = false;
            }
            else
            {
                float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;
                m_velocity += dt * new Vector2(0, -10);
                Position += dt * m_velocity;
            }
        }
    }
}
